﻿
//***********************************************************************
// * Module:   TbBstFraudFeedbackHandler
// * 作者:  曹荣芝
// * Modified: 2014/5/26
// * Purpose: Definition of the Class TbBstFraudFeedbackHandler 业务逻辑处理Handler类
// ***********************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XWG.Framework.MSException;
using XWG.Framework.AuthUtility;
using XWG.Framework.AuthEntity;
using XWG.Framework.AuthSPConst;
using XWG.Framework.AuthBLL;
using XWG.JWBST.JWBSTEntity;
using XWG.JWBST.JWBSTSPConst;
using System.Web.Script.Serialization;
using System.Data;
using XWG.Framework.Query;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using XWG.JWBST.JWBSTBLL;
using System.Collections;
using JWBSTAPP.CommonClass;
using XWG.Framework;
namespace JWBSTAPP.AjaxServer
{
    /// <summary>
    /// TbBstFraudFeedbackHandler 的摘要说明
    /// </summary>
    public class TbBstFraudFeedbackHandler : JWBSTAPP.CommonClass.HttpHandlerBase, System.Web.SessionState.IRequiresSessionState
    {

        #region 添加记录
        /// <summary>
        /// 添加记录
        /// </summary>
        protected void AddRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            try
            {

                TbBstFraudFeedback mTbBstFraudFeedback = new TbBstFraudFeedback();
                mTbBstFraudFeedback.Id = Guid.NewGuid().ToString(); //主键
                mTbBstFraudFeedback.Receivedatetime = Convert.ToDateTime(context.Request.Form["texReceivedatetime"]); //收到诈骗电话（短信）时间
                mTbBstFraudFeedback.Tel = context.Request.Form["texTel"]; //来电显示的号码
                mTbBstFraudFeedback.Fraudtype = Convert.ToDecimal(context.Request.Form["texFraudtype"]); //诈骗名义代码
                mTbBstFraudFeedback.Operatorsname = context.Request.Form["texOperatorsname"]; //被举报号码所属运营商名称 来电显示号码为非手机号的名称为其他
                mTbBstFraudFeedback.Operatorscode = context.Request.Form["texOperatorscode"]; //被举报号码所属运营商代码 1 移动号码 2 联通 3 电信 0 其他（来电显示号码为非手机号的）
                mTbBstFraudFeedback.Telattribution = context.Request.Form["texTelattribution"]; //被举报号码归属省
                mTbBstFraudFeedback.Msgcontent = context.Request.Form["texMsgcontent"]; //短信内容
                mTbBstFraudFeedback.Informername = context.Request.Form["texInformername"]; //举报人姓名
                mTbBstFraudFeedback.Informertel = context.Request.Form["texInformertel"]; //举报人电话
                mTbBstFraudFeedback.Informercompany = context.Request.Form["texInformercompany"]; //举报人单位
                mTbBstFraudFeedback.Movesign = context.Request.Form["texMovesign"]; //同步标志
                mTbBstFraudFeedback.Fraudtypecontent = context.Request.Form["texFraudtypecontent"]; //诈骗名义具体内容
                mTbBstFraudFeedback.Remark = context.Request.Form["texRemark"]; //备注
                mTbBstFraudFeedback.Ip = context.Request.Form["texIp"]; //举报人ip地址
                mTbBstFraudFeedback.Result = context.Request.Form["texResult"]; //反馈结果
                mTbBstFraudFeedback.Resultstatus = context.Request.Form["texResultstatus"]; //0 未下载 1 已下载未反馈 2 已反馈
                mTbBstFraudFeedback.Insideid = context.Request.Form["texInsideid"]; //内网民生警务平台同步出来的ID

                mResultModel = TbBstFraudFeedbackBLL.Insert(mTbBstFraudFeedback, context.Session["UserID"], true); //新建操作
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 删除记录
        /// <summary>
        /// 删除记录
        /// </summary>
        protected void DeleteRecord()
        {

            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //声明返回类型
            try
            {
                string[] arryParamKey = context.Request.Params["id"].ToString().Split(',');
                if (arryParamKey.Length == 0)
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                TbBstFraudFeedback mTbBstFraudFeedback = new TbBstFraudFeedback();
                foreach (var paramKey in arryParamKey)
                {
                    mResultModel = TbBstFraudFeedbackBLL.Delete(paramKey, context.Session["UserID"], true); //删除对应的信息
                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); ; //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, ""); //写入异常日志
                mResultModel.ErrorCode = -9999; //-9999代码是系统异常通用代码
                mResultModel.ISSucceed = false; //行为执行失败
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }

        }
        #endregion

        #region 修改记录
        /// <summary>
        /// 修改记录
        /// </summary>
        protected void EditRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            TbBstFraudFeedback mTbBstFraudFeedback = new TbBstFraudFeedback();

            string paramKey = context.Request.Params["id"];
            try
            {

                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                mTbBstFraudFeedback = TbBstFraudFeedbackBLL.Load(paramKey); //根据键值获取实体信息
                if (mTbBstFraudFeedback != null)
                {
                    mTbBstFraudFeedback.Receivedatetime = Convert.ToDateTime(context.Request.Form["texReceivedatetime"]); //收到诈骗电话（短信）时间
                    mTbBstFraudFeedback.Tel = context.Request.Form["texTel"]; //来电显示的号码
                    mTbBstFraudFeedback.Fraudtype = Convert.ToDecimal(context.Request.Form["texFraudtype"]); //诈骗名义代码
                    mTbBstFraudFeedback.Operatorsname = context.Request.Form["texOperatorsname"]; //被举报号码所属运营商名称 来电显示号码为非手机号的名称为其他
                    mTbBstFraudFeedback.Operatorscode = context.Request.Form["texOperatorscode"]; //被举报号码所属运营商代码 1 移动号码 2 联通 3 电信 0 其他（来电显示号码为非手机号的）
                    mTbBstFraudFeedback.Telattribution = context.Request.Form["texTelattribution"]; //被举报号码归属省
                    mTbBstFraudFeedback.Msgcontent = context.Request.Form["texMsgcontent"]; //短信内容
                    mTbBstFraudFeedback.Informername = context.Request.Form["texInformername"]; //举报人姓名
                    mTbBstFraudFeedback.Informertel = context.Request.Form["texInformertel"]; //举报人电话
                    mTbBstFraudFeedback.Informercompany = context.Request.Form["texInformercompany"]; //举报人单位
                    mTbBstFraudFeedback.Movesign = context.Request.Form["texMovesign"]; //同步标志
                    mTbBstFraudFeedback.Fraudtypecontent = context.Request.Form["texFraudtypecontent"]; //诈骗名义具体内容
                    mTbBstFraudFeedback.Remark = context.Request.Form["texRemark"]; //备注
                    mTbBstFraudFeedback.Ip = context.Request.Form["texIp"]; //举报人ip地址
                    mTbBstFraudFeedback.Result = context.Request.Form["texResult"]; //反馈结果
                    mTbBstFraudFeedback.Resultstatus = context.Request.Form["texResultstatus"]; //0 未下载 1 已下载未反馈 2 已反馈
                    mTbBstFraudFeedback.Insideid = context.Request.Form["texInsideid"]; //内网民生警务平台同步出来的ID

                    mResultModel = TbBstFraudFeedbackBLL.Update(mTbBstFraudFeedback, context.Session["UserID"], true); //新建操作
                }
                else
                {
                    mResultModel.ErrorCode = -9990; //没有获取所需的信息，信息可能已被删除
                    mResultModel.ISSucceed = false;

                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 获取实体记录
        /// <summary>
        /// 获取实体记录
        /// </summary>
        protected void GetModel()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            string paramKey = context.Request.Params["id"];
            Hashtable ht = new Hashtable();
            string json = "";
            string dmt = "";
            try
            {
                TbBstFraudFeedback mTbBstFraudFeedback = new TbBstFraudFeedback(); //声明实体
                if (!string.IsNullOrEmpty(paramKey))
                {
                    mTbBstFraudFeedback = TbBstFraudFeedbackBLL.Load(paramKey); //根据键值获取管理员
                    if (mTbBstFraudFeedback != null)
                    {
                        json = JsonConvert.SerializeObject(mTbBstFraudFeedback);
                    }
                    if (!string.IsNullOrEmpty(mTbBstFraudFeedback.Resultstatus))
                    {
                        string isMov = "未处理";
                        switch (mTbBstFraudFeedback.Resultstatus)
                        {
                            case "0":
                                isMov = "未下载";
                                break;
                            case "1":
                                isMov = "已下载未反馈";
                                break;
                            case "2":
                                isMov = "已反馈";
                                break;
                            default:
                                break;
                        }
                        ht.Add("Isext", isMov);
                        mTbBstFraudFeedback.Resultstatus = isMov;
                    }
                    if (mTbBstFraudFeedback.Receivedatetime.ToString("yyyy") == "0001")
                    {
                        dmt = "暂无时间数据";
                        ht.Add("ShowTime", dmt);
                    }
                    else
                    {
                        dmt = mTbBstFraudFeedback.Receivedatetime.ToString("yyyy-MM-dd HH:mm:ss");
                        ht.Add("ShowTime", dmt);
                    }
                    if (string.IsNullOrEmpty(mTbBstFraudFeedback.Result))
                    {
                        mTbBstFraudFeedback.Result = "暂无反馈结果";
                    }
                    json = JsonString.AddAttribute(json, ht);
                }
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9990;
                mResultModel.ISSucceed = false;
                json = JsonConvert.SerializeObject(mResultModel);
            }
            context.Response.Write(json);
        }
        #endregion

        #region 获取数据
        /// <summary>
        /// 获取数据记录
        /// </summary>
        protected void SELData()
        {

            TableMessage tm = new TableMessage();
            HearderMessage hm = new HearderMessage();
            List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
            context.Response.ContentType = "text/plain";
            string pageSize = context.Request["pageSize"];
            string pageIndex = context.Request["pageIndex"];
            if (String.IsNullOrEmpty(pageSize) || String.IsNullOrEmpty(pageIndex) || !AnyString.IsNumeric(pageSize) || !AnyString.IsNumeric(pageIndex))
                return;
            DataTable dtTbBstFraudFeedback = new DataTable();
            hm = new HearderMessage();
            int intPageSize = Convert.ToInt32(pageSize);
            int intPageIndex = Convert.ToInt32(pageIndex);
            string Tel = context.Request.Form["texTel"];
            string lb = context.Request["lb"];
            string ZpCode = context.Request.Form["selStatus"];    //诈骗类型
            string fkCode = context.Request.Form["selFKStatus"];  //反馈状态
            string isExport = context.Request["isExport"];
            string isCurrentPage = context.Request["isCurrentPage"];
            //string selOPERATORSCODE = context.Request.Form["selOPERATORSCODE"];  //运营商selFKStatus
            DateTime begintime = new DateTime();
            DateTime endtime = new DateTime();
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeStart"]))
            {
                begintime = Convert.ToDateTime(context.Request.Form["texTimeStart"]);
            }
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeEnd"]))
            {
                endtime = Convert.ToDateTime(context.Request.Form["texTimeEnd"]);
            }
            IsoDateTimeConverter dtConverter; string json;
            QueryByPage Q = new QueryByPage();
            QueryInfo qInfo = new QueryInfo();
            SqlConditionList sqllist = new SqlConditionList();
            if (!string.IsNullOrEmpty(Tel))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.LIKE, TbBstFraudFeedbackConst.Columns.Tel, '%' + Tel + '%'), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(ZpCode))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Fraudtype, ZpCode), SqlLogicOper.AND_LOGIC);
            }
            //if (!string.IsNullOrEmpty(mUser.Bz5))
            //{
            //    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudCollectConst.Columns.Operatorscode, mUser.Bz5), SqlLogicOper.AND_LOGIC);
            //}
            if (begintime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_LESS_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, begintime), SqlLogicOper.AND_LOGIC);
            }
            if (endtime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_MORE_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, endtime), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(fkCode))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Resultstatus, fkCode), SqlLogicOper.AND_LOGIC);
            }
            //if (isExport == "1")
            //{
            //    if (isCurrentPage == "true")
            //    {
            //        dtTbBstFraudFeedback = Q.GetRecordByPage("id 主键,tel 诈骗号码,fraudtypecontent 诈骗名义,operatorsname 运营商,createdate 举报时间,msgcontent 举报短信内容,result 处理反馈结果,remark 备注", sqllist.ToSql(), "CREATEDATE", intPageSize, intPageIndex, TbBstFraudFeedbackConst.TableName, TbBstFraudFeedbackConst.FieldKey, "").Tables[0];
            //    }
            //    else
            //    {
            //        dtTbBstFraudFeedback = Q.GetRecordByPage("id 主键,tel 诈骗号码,fraudtypecontent 诈骗名义,operatorsname 运营商,createdate 举报时间,msgcontent 举报短信内容,result 处理反馈结果,remark 备注", sqllist.ToSql(), "CREATEDATE", 0, 1, TbBstFraudFeedbackConst.TableName, TbBstFraudFeedbackConst.FieldKey, "").Tables[0];
            //    }
            //    TbBstFraudFeedbackBLL.ModifiedState(sqllist.ToSql());  //修改状态
            //    Excel.ExportFile("诈骗信息采集" + DateTime.Now.ToString("yyyMMdd") + ".xls", dtTbBstFraudFeedback);
            //}
            dtTbBstFraudFeedback = Q.GetRecordByPage("*", sqllist.ToSql(), "RECEIVEDATETIME", intPageSize, intPageIndex, TbBstFraudFeedbackConst.TableName, TbBstFraudFeedbackConst.FieldKey, "").Tables[0];
            if (dtTbBstFraudFeedback != null && dtTbBstFraudFeedback.Rows.Count > 0)
            {
                for (int i = 0; i < dtTbBstFraudFeedback.Rows.Count; i++)
                {
                    string mes = "";
                    string color = "";

                    //总状态
                    if (dtTbBstFraudFeedback.Rows[i]["RESULTSTATUS"].ToString() == "1")
                    {
                        mes = "已下载未反馈";
                        color = "326AC9";
                    }
                    else if (dtTbBstFraudFeedback.Rows[i]["RESULTSTATUS"].ToString() == "2")
                    {
                        mes = "已反馈";
                        color = "32C904";
                    }
                    else
                    {
                        mes = "未下载";
                        color = "FF0000";
                    }
                    dtTbBstFraudFeedback.Rows[i]["RESULTSTATUS"] = "<span style=\"color:#" + color + "\">" + mes + "</span>";

                }
                for (int i = 0; i < dtTbBstFraudFeedback.Columns.Count; i++)
                {
                    hm = new HearderMessage();
                    hm.name = dtTbBstFraudFeedback.Columns[i].Caption;
                    list.Add(hm);
                }
                tm.Header = list;
                tm.data = dtTbBstFraudFeedback;
                tm.totalCount = Convert.ToString((int)Q.RowCount);
            }

            dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
            json = JsonConvert.SerializeObject(tm, dtConverter);
            context.Response.Write(json);
        }
        #endregion

        #region 导出页面查询
        /// <summary>
        /// 导出
        /// </summary>
        protected void QueryRecord()
        {
            TableMessage tm = new TableMessage();
            HearderMessage hm = new HearderMessage();
            List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
            context.Response.ContentType = "text/plain";
            string pageSize = context.Request["pageSize"];
            string pageIndex = context.Request["pageIndex"];
            if (String.IsNullOrEmpty(pageSize) || String.IsNullOrEmpty(pageIndex) || !AnyString.IsNumeric(pageSize) || !AnyString.IsNumeric(pageIndex))
                return;
            DataTable dtTbBstFraudFeedback = new DataTable();
            hm = new HearderMessage();
            int intPageSize = Convert.ToInt32(pageSize);
            int intPageIndex = Convert.ToInt32(pageIndex);
            string Tel = context.Request["texTel"];
            string ZpCode = context.Request["selStatus"];    //诈骗类型
            string fkCode = context.Request["selFKStatus"];  //反馈状态
            string isExport = context.Request["isExport"];
            string isCurrentPage = context.Request["isCurrentPage"];
            //string selOPERATORSCODE = context.Request.Form["selOPERATORSCODE"];  //运营商
            DateTime begintime = new DateTime();
            DateTime endtime = new DateTime();
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeStart"]))
            {
                begintime = Convert.ToDateTime(context.Request.Form["texTimeStart"]);
            }
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeEnd"]))
            {
                endtime = Convert.ToDateTime(context.Request.Form["texTimeEnd"]);
            }
            IsoDateTimeConverter dtConverter;
            string json;
            QueryByPage Q = new QueryByPage();
            QueryInfo qInfo = new QueryInfo();
            SqlConditionList sqllist = new SqlConditionList();
            if (!string.IsNullOrEmpty(Tel))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.LIKE, TbBstFraudFeedbackConst.Columns.Tel, '%' + Tel + '%'), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(ZpCode))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Fraudtype, ZpCode), SqlLogicOper.AND_LOGIC);
            }
            //if (!string.IsNullOrEmpty(mUser.Bz5))
            //{
            //    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudCollectConst.Columns.Operatorscode, mUser.Bz5), SqlLogicOper.AND_LOGIC);
            //}
            if (begintime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_LESS_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, begintime), SqlLogicOper.AND_LOGIC);
            }
            if (endtime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_MORE_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, endtime), SqlLogicOper.AND_LOGIC);
            }
            string Yys = "resultstatus";
            if (mUser.Bz5 == "1")
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Ydrs, fkCode), SqlLogicOper.AND_LOGIC);
                }
                Yys = "ydrs";
            }
            else if (mUser.Bz5 == "2")
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Ltrs, fkCode), SqlLogicOper.AND_LOGIC);
                }
                Yys = "ltrs";
            }
            else if (mUser.Bz5 == "3")
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Dxrs, fkCode), SqlLogicOper.AND_LOGIC);
                }
                Yys = "dxrs";
            }
            else
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Resultstatus, fkCode), SqlLogicOper.AND_LOGIC);
                }
                Yys = "resultstatus";
            }
            dtTbBstFraudFeedback = Q.GetRecordByPage("ID,TEL,fraudtypecontent,operatorsname,informername,informertel,RECEIVEDATETIME," + Yys + " as resultstatus", sqllist.ToSql(), "RECEIVEDATETIME", intPageSize, intPageIndex, TbBstFraudFeedbackConst.TableName, TbBstFraudFeedbackConst.FieldKey, "").Tables[0];
            if (dtTbBstFraudFeedback != null && dtTbBstFraudFeedback.Rows.Count > 0)
            {
                for (int i = 0; i < dtTbBstFraudFeedback.Rows.Count; i++)
                {
                    string mes = "";
                    string color = "";

                    //总状态
                    if (dtTbBstFraudFeedback.Rows[i]["RESULTSTATUS"].ToString() == "1")
                    {
                        mes = "已下载未反馈";
                        color = "326AC9";
                    }
                    else if (dtTbBstFraudFeedback.Rows[i]["RESULTSTATUS"].ToString() == "2")
                    {
                        mes = "已反馈";
                        color = "32C904";
                    }
                    else
                    {
                        mes = "未下载";
                        color = "FF0000";
                    }
                    dtTbBstFraudFeedback.Rows[i]["RESULTSTATUS"] = "<span style=\"color:#" + color + "\">" + mes + "</span>";

                }
                for (int i = 0; i < dtTbBstFraudFeedback.Columns.Count; i++)
                {
                    hm = new HearderMessage();
                    hm.name = dtTbBstFraudFeedback.Columns[i].Caption;
                    list.Add(hm);
                }
                tm.Header = list;
                tm.data = dtTbBstFraudFeedback;
                tm.totalCount = Convert.ToString((int)Q.RowCount);
            }

            dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
            json = JsonConvert.SerializeObject(tm, dtConverter);
            context.Response.Write(json);
        }
        #endregion

        #region 导出数据
        /// <summary>
        /// 导出数据
        /// </summary>
        protected void QueryExcelRecord()
        {
            //TableMessage tm = new TableMessage();
            //HearderMessage hm = new HearderMessage();
            //List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
            //string pageSize = context.Request.QueryString["pageSize"].ToString();
            //string pageIndex = context.Request.QueryString["pageIndex"].ToString();
            DataTable dtTbBstFraudFeedback = new DataTable();
            //int intPageSize = Convert.ToInt32(pageSize);
            //int intPageIndex = Convert.ToInt32(pageIndex);
            string Tel = context.Request["texTel"];
            string fkCode = context.Request["selFKStatus"];  //反馈状态
            string ZpCode = context.Request["selStatus"];    //诈骗类型
            string isExport = context.Request["isExport"];
            DateTime begintime = new DateTime();
            DateTime endtime = new DateTime();
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeStart"]))
            {
                begintime = Convert.ToDateTime(context.Request.Form["texTimeStart"]);
            }
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeEnd"]))
            {
                endtime = Convert.ToDateTime(context.Request.Form["texTimeEnd"]);
            }

            QueryByPage Q = new QueryByPage();
            QueryInfo qInfo = new QueryInfo();
            SqlConditionList sqllist = new SqlConditionList();
            if (!string.IsNullOrEmpty(Tel))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.LIKE, TbBstFraudFeedbackConst.Columns.Tel, '%' + Tel + '%'), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(ZpCode))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Fraudtype, ZpCode), SqlLogicOper.AND_LOGIC);
            }
            if (begintime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_LESS_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, begintime), SqlLogicOper.AND_LOGIC);
            }
            if (endtime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_MORE_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, endtime), SqlLogicOper.AND_LOGIC);
            }

            if (isExport == "1")
            {
                if (mUser.Bz5 == "1")
                {
                    if (!string.IsNullOrEmpty(fkCode))
                    {
                        sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Ydrs, fkCode), SqlLogicOper.AND_LOGIC);
                    }
                }
                else if (mUser.Bz5 == "2")
                {
                    if (!string.IsNullOrEmpty(fkCode))
                    {
                        sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Ltrs, fkCode), SqlLogicOper.AND_LOGIC);
                    }
                }
                else if (mUser.Bz5 == "3")
                {
                    if (!string.IsNullOrEmpty(fkCode))
                    {
                        sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Dxrs, fkCode), SqlLogicOper.AND_LOGIC);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(fkCode))
                    {
                        sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Resultstatus, fkCode), SqlLogicOper.AND_LOGIC);
                    }
                }
                dtTbBstFraudFeedback = Q.GetRecordByPage("id 主键,tel 诈骗号码,fraudtypecontent 诈骗名义,RECEIVEDATETIME 收到时间,msgcontent 举报短信内容,'' 处理反馈结果,remark 备注", sqllist.ToSql(), "RECEIVEDATETIME", 0, 1, TbBstFraudFeedbackConst.TableName, TbBstFraudFeedbackConst.FieldKey, "").Tables[0];

                if (dtTbBstFraudFeedback.Rows.Count > 0)
                {
                    //type  0  下载  1上传
                    TbBstFraudOperationhistory his = new TbBstFraudOperationhistory();
                    his.Id = Guid.NewGuid().ToString();
                    his.Operationtype = "0";
                    his.Username = mUser.UserLoginname;
                    his.Operatorscode = mUser.Bz5;

                    switch (his.Operatorscode)
                    {
                        case "1":
                            his.Operatorsname = "中国移动";
                            break;
                        case "2":
                            his.Operatorsname = "中国联通";
                            break;
                        case "3":
                            his.Operatorsname = "中国电信";
                            break;
                        case "4":
                            his.Operatorsname = "其他";
                            break;
                        default:
                            his.Operatorsname = "未知用户";
                            break;
                    }
                    his.Records = dtTbBstFraudFeedback.Rows.Count;
                    his.Filepath = "";
                    his.Createdate = DateTime.Now;
                    TbBstFraudOperationhistoryBLL.Insert(his, "", false);
                    TbBstFraudFeedbackBLL.ModifiedState(sqllist.ToSql(), mUser.Bz5);  //修改状态
                    Excel.ExportFile("诈骗信息采集" + DateTime.Now.ToString("yyyMMdd") + ".xls", dtTbBstFraudFeedback);
                }
                else
                {
                    context.Response.Write(dtTbBstFraudFeedback.Rows.Count);
                }
            }
        }
        #endregion

        #region 导出数据条数
        /// <summary>
        /// 导出数据
        /// </summary>
        protected void QueryExcelRecordCount()
        {
            ResultModel re = new ResultModel();

            TableMessage tm = new TableMessage();
            HearderMessage hm = new HearderMessage();
            List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
            DataTable dtTbBstFraudFeedback = new DataTable();
            string Tel = context.Request["texTel"];
            string fkCode = context.Request.Form["selFKStatus"];  //反馈状态
            string ZpCode = context.Request["selStatus"];    //诈骗类型
            string isExport = context.Request["isExport"];
            DateTime begintime = new DateTime();
            DateTime endtime = new DateTime();
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeStart"]))
            {
                begintime = Convert.ToDateTime(context.Request.Form["texTimeStart"]);
            }
            if (!string.IsNullOrEmpty(context.Request.Form["texTimeEnd"]))
            {
                endtime = Convert.ToDateTime(context.Request.Form["texTimeEnd"]);
            }

            QueryByPage Q = new QueryByPage();
            QueryInfo qInfo = new QueryInfo();
            SqlConditionList sqllist = new SqlConditionList();
            if (!string.IsNullOrEmpty(Tel))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.LIKE, TbBstFraudFeedbackConst.Columns.Tel, '%' + Tel + '%'), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(ZpCode))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Fraudtype, ZpCode), SqlLogicOper.AND_LOGIC);
            }
            if (begintime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_LESS_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, begintime), SqlLogicOper.AND_LOGIC);
            }
            if (endtime.ToString() != "0001/1/1 0:00:00")
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_MORE_THAN, TbBstFraudFeedbackConst.Columns.Receivedatetime, endtime), SqlLogicOper.AND_LOGIC);
            }

            if (mUser.Bz5 == "1")
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Ydrs, fkCode), SqlLogicOper.AND_LOGIC);
                }
            }
            else if (mUser.Bz5 == "2")
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Ltrs, fkCode), SqlLogicOper.AND_LOGIC);
                }
            }
            else if (mUser.Bz5 == "3")
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Dxrs, fkCode), SqlLogicOper.AND_LOGIC);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(fkCode))
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstFraudFeedbackConst.Columns.Resultstatus, fkCode), SqlLogicOper.AND_LOGIC);
                }
            }
            dtTbBstFraudFeedback = Q.GetRecordByPage("id 主键,tel 诈骗号码,fraudtypecontent 诈骗名义,operatorsname 运营商,createdate 举报时间,msgcontent 举报短信内容,'' 处理反馈结果,remark 备注", sqllist.ToSql(), "RECEIVEDATETIME", 0, 1, TbBstFraudFeedbackConst.TableName, TbBstFraudFeedbackConst.FieldKey, "").Tables[0];

            if (dtTbBstFraudFeedback != null && dtTbBstFraudFeedback.Rows.Count > 0)
            {
                re.ISSucceed = true;
                re.FiledKey = dtTbBstFraudFeedback.Rows.Count.ToString();

            }
            else
            {
                re.ISSucceed = false;
                re.FiledKey = "0";
            }

            context.Response.Write(JsonConvert.SerializeObject(re));
        }
        #endregion
    }
}


